<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    //1.求最大函数

    // function getMax(x,y){
    //   return x > y ? x : y

    // }
    // let max = getMax(45,59)
    // console.log(max)
    

    //2.求任意数组的最大值，并返回
 
    function fn(arr =[]){
      let max = arr[0]
      for (let i =0 ; i < arr.length; i++){
        if (max < arr[i]){ 
          max = arr[i]
        }
      }
      return max
    }
      let max = fn([1,3,5,7,9 ]) 
      console.log(max)

  //      function fn(arr =[]){
  //     let min = arr [0]
  //     for (let i =1 ; i < arr.length; i++){
  //       if (min > arr[i]){ 
  //         max = arr[i]
  //       }
  //     }
  //     return min
  //   }
  //  let min = fn([1,3,5,7,9 ])
  //  console.log(min)

  </script>
</body>
</html>